import axios from 'axios';
import type { RouteRecordNormalized } from 'vue-router';
import { UserState } from '@/store/modules/user/types';

export interface LoginData {
  email: string;
  password: string;
  key: number;
  verifyCode: string;
}

export interface LoginRes {
  userId: number;
  token: string;
}
export function login(data: LoginData) {
  // return axios.post<LoginRes>('/client-api/user/login', data);
  // data.email = '';
  const rr = {
    data: {
      userId: 4,
      token: 'asdfasdffdasfads'
    }
  }
  return rr
}

export function getPermission(userId: number) {
  return axios.get(`/admin-api/permission/list/permissionList/${userId}`);
}

export function logout() {
  return axios.post<LoginRes>('/api/user/logout');
}

export function getUserInfo() {
  return axios.post<UserState>('/api/user/info');
}

export function getMenuList() {
  return axios.post<RouteRecordNormalized[]>('/api/user/menu');
}
